#include "MessageObjectNode.h"
int MessageObjectNode::messageObjectCount = 0;
MessageObjectNode::MessageObjectNode(ID _id, std::string meshName)
:	id(_id),
	sceneNode(0)
{
	messageObjectCount++;
	createSceneNode(meshName);
}

//--------------------------------------------------------------
MessageObjectNode::~MessageObjectNode(void)
{
}

//--------------------------------------------------------------
void MessageObjectNode::createSceneNode(std::string meshName)
{
	Ogre::SceneManager* sceneManager = Ogre::Root::getSingleton().getSceneManager("mainSceneManager");

	Ogre::Entity* entity = sceneManager->createEntity("messageObjectCount" + Ogre::StringConverter::toString(messageObjectCount), meshName);
	sceneNode = sceneManager->getRootSceneNode()->createChildSceneNode();
	sceneNode->attachObject(entity);
	
}

//--------------------------------------------------------------
Ogre::Vector3 MessageObjectNode::getDirection()
{
	Ogre::Matrix3 matrix;
	sceneNode->getOrientation().ToRotationMatrix(matrix);

	return matrix.GetColumn(2);
}

//--------------------------------------------------------------
Ogre::Vector3 MessageObjectNode::getUpVector()
{
	Ogre::Matrix3 matrix;
	sceneNode->getOrientation().ToRotationMatrix(matrix);

	return matrix.GetColumn(1);
}

//--------------------------------------------------------------
Ogre::Vector3 MessageObjectNode::getRightVector()
{
	Ogre::Matrix3 matrix;
	sceneNode->getOrientation().ToRotationMatrix(matrix);

	return matrix.GetColumn(0);
}